package cn.dnf.controller;

import cn.dnf.domain.Relation;
import cn.dnf.domain.Ticket;
import cn.dnf.domain.User;
import cn.dnf.exception.GlobalCustomException;
import cn.dnf.feign.UserFeignClients;
import cn.dnf.service.IMovieService;
import cn.dnf.service.IRelationService;
import cn.dnf.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/movie")
public class MovieController {
@Autowired
private IMovieService movieService;
@Autowired
private UserFeignClients userFeignClients;
@Autowired
private IRelationService relationService;
    @GetMapping("/findAll")
    public List<Ticket> findAll(){
       return movieService.findAll();
    }

    @GetMapping("/findById/{id}")
    public Ticket findById(@PathVariable Long id){
        return movieService.findById(id);
    }

    @PostMapping("/update")
    public void update(@RequestBody Ticket ticket){

        movieService.update(ticket);
    }
    @GetMapping("/watch/{id}")
    public JsonResult watch(@PathVariable Long id) {

            return movieService.watch(id);

    }

    @PostMapping("/gift")
    void gift(@RequestBody User user){
        movieService.gift(user);
    };



}
